<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>连接池爆满问题排查指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        .step-number {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }
        .content-card {
            backdrop-filter: blur(10px);
            background: rgba(255, 255, 255, 0.95);
        }
        .highlight-box {
            border-left: 4px solid #667eea;
            background: linear-gradient(to right, rgba(102, 126, 234, 0.1), transparent);
        }
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
        .icon-box {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            width: 48px;
            height: 48px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 12px;
            font-size: 20px;
        }
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            bottom: -8px;
            width: 60px;
            height: 3px;
            background: linear-gradient(to right, #667eea, #764ba2);
            border-radius: 2px;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto">
            <div class="text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6 leading-tight">
                    连接池爆满问题
                    <span class="block text-3xl md:text-4xl mt-2 font-light opacity-90">完整排查指南</span>
                </h1>
                <p class="text-xl md:text-2xl font-light max-w-3xl mx-auto opacity-90 leading-relaxed">
                    深入剖析连接池问题的根源，提供系统化的排查方法和优化策略，助您快速定位并解决数据库连接瓶颈
                </p>
                <div class="mt-10 flex justify-center space-x-8">
                    <div class="text-center">
                        <i class="fas fa-database text-4xl mb-2"></i>
                        <p class="text-sm opacity-80">数据库优化</p>
                    </div>
                    <div class="text-center">
                        <i class="fas fa-chart-line text-4xl mb-2"></i>
                        <p class="text-sm opacity-80">性能监控</p>
                    </div>
                    <div class="text-center">
                        <i class="fas fa-tools text-4xl mb-2"></i>
                        <p class="text-sm opacity-80">问题诊断</p>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="max-w-6xl mx-auto px-6 py-12">
        <!-- Introduction Card -->
        <div class="content-card rounded-2xl shadow-xl p-8 mb-12">
            <div class="flex items-start space-x-4">
                <div class="icon-box">
                    <i class="fas fa-exclamation-triangle"></i>
                </div>
                <div class="flex-1">
                    <h2 class="text-2xl font-bold text-gray-800 mb-3">问题概述</h2>
                    <p class="text-gray-600 leading-relaxed text-lg">
                        排查连接池爆满问题是一项复杂的任务，通常涉及多个层面和因素的分析。本指南将带您系统地了解问题诊断流程，从症状确认到根本原因分析，再到优化方案的实施。
                    </p>
                </div>
            </div>
        </div>

        <!-- Diagnostic Flow Chart -->
        <div class="content-card rounded-2xl shadow-xl p-8 mb-12">
            <h2 class="text-3xl font-bold text-gray-800 mb-6 relative section-title">诊断流程图</h2>
            <div class="mermaid">
                graph TD
                    A[连接池爆满问题] --> B{确认症状}
                    B --> C[应用响应变慢]
                    B --> D[数据库连接数过多]
                    C --> E[监控和日志分析]
                    D --> E
                    E --> F{是否存在连接泄漏}
                    F -->|是| G[连接泄漏检测]
                    F -->|否| H[SQL执行时间分析]
                    G --> I[代码审查与修复]
                    H --> J[慢查询优化]
                    I --> K[连接池配置优化]
                    J --> K
                    K --> L[负载测试验证]
                    L --> M{问题是否解决}
                    M -->|否| N[考虑横向扩展]
                    M -->|是| O[总结和预防]
            </div>
        </div>

        <!-- Steps Grid -->
        <div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-12">
            <!-- Step 1 -->
            <div class="content-card rounded-2xl shadow-lg p-8 card-hover">
                <div class="flex items-center mb-4">
                    <span class="step-number text-5xl font-bold mr-4">1</span>
                    <h3 class="text-2xl font-bold text-gray-800">确认问题症状</h3>
                </div>
                <p class="text-gray-600 mb-4 leading-relaxed">
                    首先需要确认连接池爆满的具体症状，比如是应用程序响应变慢，还是数据库出现过多连接。
                </p>
                <div class="highlight-box p-4 rounded-lg">
                    <p class="text-sm text-gray-700">
                        <i class="fas fa-lightbulb text-purple-600 mr-2"></i>
                        通过查看连接池的监控日志、数据库的连接数以及应用的响应时间来确认问题
                    </p>
                </div>
            </div>

            <!-- Step 2 -->
            <div class="content-card rounded-2xl shadow-lg p-8 card-hover">
                <div class="flex items-center mb-4">
                    <span class="step-number text-5xl font-bold mr-4">2</span>
                    <h3 class="text-2xl font-bold text-gray-800">监控和日志分析</h3>
                </div>
                <ul class="space-y-3 text-gray-600">
                    <li class="flex items-start">
                        <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                        <div>
                            <strong>日志分析：</strong>查看应用日志，寻找异常的连接数增加、连接泄漏或未关闭连接的情况
                        </div>
                    </li>
                    <li class="flex items-start">
                        <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                        <div>
                            <strong>监控工具：</strong>利用Prometheus、Grafana等工具监控连接池使用情况
                        </div>
                    </li>
                </ul>
            </div>

            <!-- Step 3 -->
            <div class="content-card rounded-2xl shadow-lg p-8 card-hover">
                <div class="flex items-center mb-4">
                    <span class="step-number text-5xl font-bold mr-4">3</span>
                    <h3 class="text-2xl font-bold text-gray-800">连接泄漏检测</h3>
                </div>
                <div class="space-y-4">
                    <div class="bg-purple-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-purple-800 mb-2">
                            <i class="fas fa-robot mr-2"></i>自动化工具
                        </h4>
                        <p class="text-sm text-gray-700">
                            使用HikariCP等连接池的泄漏检测功能，自动检测长时间未关闭的连接
                        </p>
                    </div>
                    <div class="bg-purple-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-purple-800 mb-2">
                            <i class="fas fa-code mr-2"></i>代码审查
                        </h4>
                        <p class="text-sm text-gray-700">
                            检查数据库连接使用逻辑，确保所有连接都正确关闭
                        </p>
                    </div>
                </div>
            </div>

            <!-- Step 4 -->
            <div class="content-card rounded-2xl shadow-lg p-8 card-hover">
                <div class="flex items-center mb-4">
                    <span class="step-number text-5xl font-bold mr-4">4</span>
                    <h3 class="text-2xl font-bold text-gray-800">SQL执行时间分析</h3>
                </div>
                <div class="space-y-3">
                    <div class="flex items-start">
                        <i class="fas fa-clock text-purple-600 mt-1 mr-3"></i>
                        <div>
                            <strong>慢查询分析：</strong>分析数据库慢查询日志，优化长时间运行的查询
                        </div>
                    </div>
                    <div class="flex items-start">
                        <i class="fas fa-search text-purple-600 mt-1 mr-3"></i>
                        <div>
                            <strong>索引优化：</strong>确保数据库表索引优化到位，避免全表扫描
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Optimization Strategies -->
        <div class="content-card rounded-2xl shadow-xl p-8 mb-12">
            <h2 class="text-3xl font-bold text-gray-800 mb-8 relative section-title">优化策略</h2>
            <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                <!-- Strategy 1 -->
                <div class="bg-gradient-to-br from-purple-50 to-pink-50 p-6 rounded-xl">
                    <div class="icon-box mb-4">
                        <i class="fas fa-cogs"></i>
                    </div>
                    <h3 class="text-xl font-bold text-gray-800 mb-3">连接池配置优化</h3>
                    <ul class="space-y-2 text-gray-600 text-sm">
                        <li>• 合理设置最大连接数</li>
                        <li>• 优化空闲连接回收策略</li>
                        <li>• 调整连接存活时间</li>
                    </ul>
                </div>

                <!-- Strategy 2 -->
                <div class="bg-gradient-to-br from-blue-50 to-indigo-50 p-6 rounded-xl">
                    <div class="icon-box mb-4">
                        <i class="fas fa-expand-arrows-alt"></i>
                    </div>
                    <h3 class="text-xl font-bold text-gray-800 mb-3">负载分流和扩展</h3>
                    <ul class="space-y-2 text-gray-600 text-sm">
                        <li>• 实施读写分离</li>
                        <li>• 数据库水平分割</li>
                        <li>• 增加应用实例</li>
                    </ul>
                </div>

                <!-- Strategy 3 -->
                <div class="bg-gradient-to-br from-green-50 to-teal-50 p-6 rounded-xl">
                    <div class="icon-box mb-4">
                        <i class="fas fa-layer-group"></i>
                    </div>
                    <h3 class="text-xl font-bold text-gray-800 mb-3">应用层优化</h3>
                    <ul class="space-y-2 text-gray-600 text-sm">
                        <li>• 实现连接复用</li>
                        <li>• 引入缓存机制</li>
                        <li>• 批处理数据库操作</li>
                    </ul>
                </div>
            </div>
        </div>

        <!-- Database Configuration -->
        <div class="content-card rounded-2xl shadow-xl p-8 mb-12">
            <h2 class="text-3xl font-bold text-gray-800 mb-6 relative section-title">数据库配置优化</h2